package com.yanqu.road.server.cmd.union.cross.huaben;

import com.yanqu.road.entity.config.goods.OpenGoodsBagResult;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.union.cross.UnionHuaBenProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.union.cross.UnionHuaBenModule;
import com.yanqu.road.server.manger.config.GoodsBagMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.ArrayList;

@Cmd(code = Protocol.S_CROSS_UNION_HUA_BEN_PATRONS_DISPATCH_FROM_CROSS, desc = "门客派遣")
public class UnionHuaBenDispatchCmdFromCross extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        UnionHuaBenProto.UnionHuaBenDispatchCrossRespMsg respMsg = UnionHuaBenProto.UnionHuaBenDispatchCrossRespMsg.parseFrom(packet.getBytes());

        if(respMsg.getRet() == 0){

            player.getModule(CurrencyModule.class).addCurrency(respMsg.getReward(), eLogMoneyType.CrossUnionHuaBen, eLogMoneyType.CrossUnionHuaBenMonsterAttackReward);

            //门客次数
            //player.getModule(UnionHuaBenModule.class).addSendTime(new ArrayList<>(respMsg.getPatronsIdList()));

        }else {
            //门客次数归还
            player.getModule(UnionHuaBenModule.class).restoreTime(new ArrayList<>(respMsg.getPatronsIdList()));
        }

        player.sendPacket(Protocol.U_CROSS_UNION_HUA_BEN_PATRONS_DISPATCH, respMsg.toBuilder());

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
